<?php
//include('functions.php');
//db();
if(!$_POST['submit'] && $_POST['submit']!="Save"){
	
}else{
	//var_dump($_POST);
	//echo $_POST['submit'];
	//read in values
	$postarr = $_POST;
	$cnt = 0;
	$siteid = $site['id'];
	//setup all the various fieldtypes and their delimiters
	//int
		$notquoted = array("id","site_id","parent_id","author_id","type_id","event_agegroup","event_childrenwelcome","event_per","event_isonsite","coord_id","event_ischildcare",
			"cc_per","cc_isonsite","cc_coordinator_id","cc_agegroup");

	//text
		$quoted = array("title","post","tags","starttime","endtime","cost","event_addr","event_addr2","event_city","event_state","event_zip","childcare_cost","cc_addr",
			"cc_addr2","cc_city","cc_state","cc_zip","need_answer","contactname","contactphone","contactemail","cc_contactname","cc_contactphone","cc_contactemail");

	//datetime
		$datetimearr = array("publishdate");

	//date
		$datearr = array("startdate","enddate","need_answereddate");
	
	// save data to database
	if($_POST['postid'] && $_POST['postid'] > 0){
		//update
		$postid = $_POST['postid'];
		$qrystr = 'UPDATE posts SET ';
		$cnt = 0;
		foreach($postarr as $post=>$value){
			if($post!=='postid' && $post!='submit' && $post!='addtype'){
				if(in_array($post,$quoted) == true){
					if($cnt != 0){ $qrystr .= ',';}
						$qrystr .= $post."='".trim($value)."'";
				}else if(in_array($post,$notquoted) == true){
					if($cnt != 0){ $qrystr .= ',';}
					$qrystr .= $post."=".$value;
				}else if(in_array($post,$datetimearr) == true){
					if($cnt != 0){ $qrystr .= ',';}
					$newvalue = date('Y-m-d',dateUnformat($value));
					$qrystr .= $post."='".$newvalue."'";
				}else if(in_array($post,$datearr) == true){
					if($cnt != 0){ $qrystr .= ',';}
					$newvalue = date('Y-m-d',dateUnformat($value));
					$qrystr .= $post."='".$newvalue."'";
				}else{
					//echo 'unknown fieldtype';
				}
				$cnt++;
			}
		}
		$qrystr .= ' WHERE id='.$postid;
		echo '<div style="width: 500px;">qry: '.$qrystr.'</div><br />';
	}else{
		//insert
		$postid = $_POST['postid'];
		$qrystr = 'INSERT INTO posts (';
		$fieldcnt = 0;
		$cnt = 0;
		foreach($postarr as $field=>$value){
			if($fieldcnt  != 0){ $qrystr .= ',';}
			$qrystr .= $field;
			$fieldcnt++;
		}
		$qrystr .= ') VALUES (';
		foreach($postarr as $post=>$value){
			if($post!=='postid' && $post!='submit' && $post!='addtype'){
				if($value==""){$value=" ";}
				if(in_array($post,$quoted) == true){
					if($cnt != 0){ $qrystr .= ',';}
					if($value !=""){$newvalue = trim($value);}else{$newvalue = '';}
						$qrystr .= "'".urlencode($newvalue)."'";
				}else if(in_array($post,$notquoted) == true){
					if($cnt != 0){ $qrystr .= ',';}
					$qrystr .= $value;
				}else if(in_array($post,$datetimearr) == true){
					if($cnt != 0){ $qrystr .= ',';}
					$newvalue = date('Y-m-d',dateUnformat($value));
					$qrystr .= "'".$newvalue."'";
				}else if(in_array($post,$datearr) == true){
					if($cnt != 0){ $qrystr .= ',';}
					$newvalue = date('Y-m-d',dateUnformat($value));
					$qrystr .= "'".$newvalue."'";
				}else{
					//echo 'unknown fieldtype';
				}
				
				$cnt++;
			}
		}
		$qrystr .= ')';
		echo 'qry: '.$qrystr.'<br />';
	}
}
if($_POST['postid'] && $_POST['postid']!=""){
	$postid = $_POST['postid'];
	$siteid = $site['id'];
	//echo $postid;
	if($postid!='add'){
		if($postid > 0){ 
			$postqry = dbSelect('posts',array("id=$postid"));
			if(mysql_numrows($postqry)==1){
				$thispost = mysql_fetch_array($postqry);
				$typeid = $thispost['type_id'];
				if($typeid >= 1){
					$post_type_qry = dbSelect('post_types',"","ORDER BY ord");
					$typename = 'Content';
					$typeid = $thispost['type_id'];
				}
				$eventtypeqry = dbSelect('ddl_event_type',"","ORDER BY ord");
				$agegroupqry = dbSelect('ddl_agegroup',"","ORDER BY ord");
				$agegroupqry = dbSelect('ddl_cc_agegroup',"","ORDER BY ord");
				$eventperqry = dbSelect('ddl_event_per',"","ORDER BY ord");
				$ccperqry = dbSelect('ddl_cc_per',"","ORDER BY ord");
				$timesqry =  dbSelect('ddl_times',"");
				$endtimesqry =  dbSelect('ddl_times',"");
			} //postid was found and we have content
			} //postid is something legit, like Golden Corral
		
		}else{
			if($_POST['addtype'] && $_POST['addtype']!=""){
				$typecode = $_POST['addtype'];
				if($typecode  == 'feed'){
					$typeid = 1;
				}else if($typecode == 'event'){
					$typeid = 2;
					$typename = 'Event'; 
				}else if($typecode == 'vision'){
					$typeid = 9;
				}else if($typecode == 'prayer'){
					$typeid = 3;
					$typename = 'Prayer Request';
				}else if($typecode == 'people'){
					$typeid = 4;
					$typename = 'People Need'; 
				}else if($typecode == 'stuff'){
					$typeid = 5;
					$typename = 'Stuff Need';
				}else if($typecode == 'money'){
					$typeid = 6;
					$typename = 'Money Need';
				}
				
			}
		} // postid is not add
				$event_coordqry = dbSelect('sites_users',array("site_id=$siteid","usertype_id=2"));
				$cc_coordqry = dbSelect('sites_users',array("site_id=$siteid","usertype_id=3"));
				$needs_coordqry = dbSelect('sites_users',array("site_id=$siteid","usertype_id=4"));
				$prayer_coordqry = dbSelect('sites_users',array("site_id=$siteid","usertype_id=5"));
				$people_coordqry = dbSelect('sites_users',array("site_id=$siteid","usertype_id=6"));
				$stuff_coordqry = dbSelect('sites_users',array("site_id=$siteid","usertype_id=7"));
				$money_coordqry = dbSelect('sites_users',array("site_id=$siteid","usertype_id=8"));
				if($typeid == 2){$typename = 'Event'; $coordqry = $event_coordqry;}
				if($typeid == 3){$typename = 'Prayer Request'; $coordqry = $prayer_coordqry;}
				if($typeid == 4){$typename = 'People Need'; $coordqry = $people_coordqry;}
				if($typeid == 5){$typename = 'Stuff Need'; $coordqry = $stuff_coordqry;}
				if($typeid == 6){$typename = 'Money Need'; $coordqry = $money_coordqry;}
	} //postid is set to something
		$post_type_qry = dbSelect('post_types',"","ORDER BY ord");
		$agegroupqry = dbSelect('ddl_agegroup',"","ORDER BY ord");
		$ccagegroupqry = dbSelect('ddl_cc_agegroup',"","ORDER BY ord");
		$eventperqry = dbSelect('ddl_event_per',"","ORDER BY ord");
		$ccperqry = dbSelect('ddl_cc_per',"","ORDER BY ord");
		$timesqry =  dbSelect('ddl_times',"");
		$endtimesqry =  dbSelect('ddl_times',"");
	?>
	<form id="postform" name="postform" action="<?php echo $thisroot ?>/post.php" method="post" width="600px">
	<h2><?php echo $typename; ?> Editor</h2>
	<div class="moreinfo_outer">
	<table width="600px" border="0">
		<!---title---><tr>
			<td><span class="inputlabel">Title: </span></td>
			<td colspan="2"><input class="largeprint" id="title" name="title" size="50" value="<?php if($thispost['title']){echo $thispost['title'];} ?>" /></td>
		</tr><!---/title--->
		<!---type/published--->
		<tr>
			<td><span class="inputlabel">Type:</span></td>
			<td><select id="type_id" name="type_id" onclick="showPanel();">
				<option value="-1">--select option--</option>
				<?php
				while($post_type_row = mysql_fetch_array($post_type_qry)){
				if($typeid==$post_type_row['id']){$selected = ' SELECTED ';}else{$selected = '';}
				echo '<option value="'.$post_type_row['id'].'" '.$selected.'>'.$post_type_row['type'].'</option>';
				}
				?>
				</select>
			</td>
			<td>
				<table>
					<tr>
						<td valign="middle"><span class="inputlabel">Published:</span></td>
						<td valign="middle"><input type="text" id="publishdate" name="publishdate" size="10" onblur="datePickerClosed('publishdate');" value="<?php if($thispost['publishdate']!="0000-00-00" && $thispost['publishdate']!=""){echo date("m/d/Y",dateFormat($thispost['publishdate']));}else{echo date("m/d/Y");} ?>" /></td>
						<td valign="middle"><img src="<?php echo $o['root']; ?>/js/datepicker/cal.png" onblur="datePickerClosed('publishdate');" onclick="displayDatePicker('publishdate');" /></td>
					</tr>
				</table>
			</td>
		</tr>
		<!---/type/published--->
		<!---start/end dates--->
	<?php if($typeid==2){ ?>
		<tr>
			<td><span class="inputlabel">Start:</span></td>
			<td>
				<table>
					<tr>
						<td>
							<input type="text" id="startdate" name="startdate" size="10" onblur="datePickerClosed('startdate');" value="<?php if($thispost['startdate']!="0000-00-00" && $thispost['startdate']!=""){echo date("m/d/Y",dateFormat($thispost['startdate']));} ?>" />
						</td>
						<td valign="middle"><img src="<?php echo $o['root']; ?>/js/datepicker/cal.png" onblur="datePickerClosed('startdate');" onclick="displayDatePicker('startdate');" /></td>
						<td><select id="starttime" name="starttime">
								<option value="-1">--select--</option>
								<?php
								while($timesrow = mysql_fetch_array($timesqry)){
								if($thispost['starttime']==$timesrow['time']){$selected = ' SELECTED ';}else{$selected = '';}
								echo '<option value="'.$timesrow['time'].'" '.$selected.'>'.$timesrow['time'].'</option>';
								}
								?>
							</select>
						</td>
					</tr>
				</table>
			</td>
			<td>
				<table>
					<tr>
						<td><span class="inputlabel">End:</span></td>
						<td><input type="text" id="enddate" name="enddate" size="10" onblur="datePickerClosed('enddate');" value="<?php if($thispost['enddate']!="0000-00-00" && $thispost['enddate']!=""){echo date("m/d/Y",dateFormat($thispost['enddate']));}  ?>" /></td>
						<td valign="middle"><img src="<?php echo $o['root']; ?>/js/datepicker/cal.png" onblur="datePickerClosed('enddate');" onclick="displayDatePicker('enddate');" /></td>
						<td>
							<select id="endtime" name="endtime">
								<option value="-1">--select--</option>
								<?php	while($endtimesrow = mysql_fetch_array($endtimesqry)){
								if($thispost['endtime']==$endtimesrow['time']){$selected = ' SELECTED ';}else{$selected = '';}
								echo '<option value="'.$endtimesrow['time'].'" '.$selected.'>'.$endtimesrow['time'].'</option>';
								} ?>
							</select>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<!---/start/end dates--->
		<!---post body--->
	<?php } //end events inclusion ?>
		<tr>
			<td colspan="3"><textarea class="mceEditor" rows="7" style="width: 590px;"  id="post" name="post"><?php if($thispost['post']){echo urldecode($thispost['post']);} ?></textarea></td>
		</tr>
		<!---/post body--->
		<!---tags--->
		<tr><td valign="bottom"><span class="inputlabel">Tags:</span></td>
			<td colspan="2">
				<span class="inputlabelsmall">comma separated like this: water, africa, denver, crisis pregnancy, etc...</span>
				<input type="text" id="tags" name="tags" style="width: 100%;" value="<?php if($thispost['tags']!=""){echo urldecode($tags); } ?>"/>
			</td>
		</tr>
		<!---/tags--->
		<!---location/cost--->
		<?php if($typeid==2 || $typeid==4 || $typeid==5 || $typeid==6){ ?>
		<tr><td colspan="3"><div class="post_editor_title">Location and Cost</div></td></tr>
		<tr>
			<td colspan="2">
			<?php if($typeid==2){$onsitemod = 'Hosted';}else if($typeid==4){$onsitemod = 'Help Needed';}else if($typeid==5 || $typeid==6){$onsitemod = 'Donations Accepted';} ?>
				<span class="inputlabel"><?php echo $onsitemod; ?> On-Site?</span><?php yesNoDdl('event_isonsite',1); ?>
			</td>
			<td>
				<span class="inputlabel">Cost: </span><span class="inputlabel"> $</span>
				<input id="cost" name="cost" size="15" value="<?php if($thispost['cost']){echo $thispost['cost'];} ?>" />
			<?php if($typeid==2){ ?>
				<select id="event_per" name="event_per">
					<option value="-1">--select--</option>
					<?php	while($eventperrow = mysql_fetch_array($eventperqry)){
						if($thispost[type_id]==$eventperrow['id']){$selected = ' SELECTED ';}else{$selected = '';}
						echo '<option value="'.$eventperrow['id'].'" '.$selected.'>'.$eventperrow['per'].'</option>';
					} ?>
				</select>
			<?php } ?>
			</td>
		</tr>
		<?php } ?>
		<!---/location/cost--->
		<!---child/ages--->
	<?php if($typeid==2){ ?>
		<tr><td colspan="2"><span class="inputlabel">Children&nbsp;may&nbsp;attend? </span><?php yesNoDdl('event_childrenwelcome',0); ?></td>
			<td>
				<span class="inputlabel">Ages:</span>
				<select id="event_agegroup" name="event_agegroup">
					<option value="-1">--select option--</option>
					<?php
					while($agegrouprow = mysql_fetch_array($agegroupqry)){
					if($thispost[type_id]==$agegrouprow['id']){$selected = ' SELECTED ';}else{$selected = '';}
					echo '<option value="'.$agegrouprow['id'].'" '.$selected.'>'.$agegrouprow['agegroup'].'</option>';
					}
					?>
				</select>
			</td>
		</tr>
		<tr>
			<td colspan="3">
				<div id="eventaddr" class="post_subsection" style="display: none; margin: 0px 0px 0px 60px;">
					<span class="inputlabel">Other Location</span>
					<table>
						<tr><td valign="top"><span class="inputlabel">Address:</span></td>
							<td><input type="text" id="event_addr" name="event_addr" size="30" value="<?php if($thispost['event_addr']){echo $thispost['event_addr'];} ?>" /></td>
						</tr>
						<tr><td valign="top"><span class="inputlabel">Address2:</span></td>
							<td><input type="text" id="event_addr2" name="event_addr2" size="30" /></td>
						</tr>
						<tr><td valign="top"><span class="inputlabel">City,&nbsp;St,&nbsp;Zip:</span></td>
							<td>
								<input type="text" id="event_city" name="event_city" size="15" value="<?php if($thispost['event_city']){echo $thispost['event_city'];} ?>" />
								<input type="text" id="event_state" name="event_state" style="width: 30px;" value="<?php if($thispost['event_state']){echo $thispost['event_state'];} ?>" />
								<input type="text" id="event_zip" name="event_zip" style="width: 50px;" value="<?php if($thispost['event_zip']){echo $thispost['event_zip'];} ?>" />
							</td>
						</tr>
						<tr><td></td><td colspan="2"><span class="inputlabelsmall">a map link will be created for you.</span></td>
						</tr>
					</table>
				</div>
			</td>
		</tr>
		<?php } ?>
	<!---/child/ages--->
	<!---coord--->	
	<?php if($typeid < 8){ ?>	
		<tr>
			<td colspan="3">
				<?php if($typeid == 2){ ?>	
					<div class="post_editor_title">Event Coordinator</div>
				<?php }else if($typeid >= 3 && $typeid <= 6){ ?>	
					<div class="post_editor_title">Needs Coordinator</div>
				<?php } ?>
			</td>
		</tr>
		<tr>
			<td colspan="2"  valign="top">
					<span class="inputlabelsmall">select a coordinator<br />(will auto-fill Contact Details)</span><br />
				<?php if($typeid >= 3 && $typeid <= 6){ ?>	
						<span class="inputlabel">Needs Coord:</span><br />
						<select id="coord_id" name="coord_id">
						<option value="-1">--select option--</option>
						<!---<option value="x">(fill in contact at right)</option>--->
						<?php
							while($coordrow = mysql_fetch_array($needs_coordqry)){
							$thisuserid = $coordrow['user_id'];
							$userrow = mysql_fetch_array(dbSelect('users',array("id=$thisuserid")));
							if($thispost[type_id]==$coordrow['id']){$selected = ' SELECTED ';}else{$selected = '';}
							echo '<option value="'.$coordrow['id'].'" '.$selected.'>'.$userrow['firstname'].' '.$userrow['lastname'].'</option>';
							}
						?>
					</select>
					<br /><br />
				<?php } ?>
					<?php $typenamearr = explode(' ',$typename); $typenameshort = $typenamearr[0]; ?>
					<span class="inputlabel"><?php echo $typenameshort; ?> Coord:</span><br />
					<select id="coord_id" name="coord_id">
						<option value="-1">--select option--</option>
						<!---<option value="x">(fill in contact at right)</option>--->
						<?php
							while($coordrow2 = mysql_fetch_array($coordqry)){
							$thisuserid2 = $coordrow2['user_id'];
							$userrow2 = mysql_fetch_array(dbSelect('users',array("id=$thisuserid2")));
							if($thispost[type_id]==$coordrow2['id']){$selected = ' SELECTED ';}else{$selected = '';}
							echo '<option value="'.$coordrow2['id'].'" '.$selected.'>'.$userrow2['firstname'].' '.$userrow2['lastname'].'</option>';
							}
						?>
					</select>
					<br /><br /><span class="inputlabelsmall">or fill in someone else on the right</span>
			</td>
			<td>
					<table>
						<tr><td colspan="2"><h2><small>Contact Details</small></h2></td></tr>
						<tr><td valign="top"><span class="inputlabel">Name:</span></td>
							<td><input type="text" id="contactname" name="contactname" size="20" value="<?php if($thispost['contactname']){echo $thispost['contactname'];} ?>" /></td>
						</tr>
						<tr><td valign="top"><span class="inputlabel">Phone:</span></td>
							<td><input type="text" id="contactphone" name="contactphone" size="20" value="<?php if($thispost['contactphone']){echo $thispost['contactphone'];} ?>" /></td>
						</tr>
						<tr><td valign="top"><span class="inputlabel">Email:</span></td>
							<td><input type="text" id="contactemail" name="contactemail" size="30" value="<?php if($thispost['contactemail']){echo $thispost['contactemail'];} ?>" /></td>
						</tr>
					</table>
			</td>
		</tr>
		<?php } ?>
		<!---/coord--->
		<!---event childcare--->
		<?php if($typeid==2){ ?>
		<tr><td colspan="3"><div class="post_editor_title">Childcare</div></td></tr>
		<tr>
			<td colspan="2"><span class="inputlabel">Childcare Provided?</span><?php yesNoDdl('event_ischildcare',0); ?></td>
			<td><span class="inputlabel">Ages:</span>
				<select id="cc_agegroup" name="cc_agegroup">
					<option value="-1">--select option--</option>
					<?php
					while($ccagegrouprow = mysql_fetch_array($ccagegroupqry)){
					if($thispost[type_id]==$ccagegrouprow['id']){$selected = ' SELECTED ';}else{$selected = '';}
					echo '<option value="'.$ccagegrouprow['id'].'" '.$selected.'>'.$ccagegrouprow['cc_agegroup'].'</option>';
					}
					?>
				</select>
			</td>
		</tr>
		<tr>
			<td colspan="2"><span class="inputlabel">On-Site?</span><?php yesNoDdl('cc_isonsite',1); ?></td>
			<td><span class="inputlabel">Cost:</span><span class="inputlabel">$</span><input id="childcare_cost" name="childcare_cost" size="5" value="<?php if($thispost['childcare_cost']){echo $thispost['childcare_cost'];} ?>" />
				<select id="cc_per" name="cc_per">
					<option value="-1">--select--</option>
					<?php
					while($ccperrow = mysql_fetch_array($ccperqry)){
					if($thispost[type_id]==$ccperrow['id']){$selected = ' SELECTED ';}else{$selected = '';}
					echo '<option value="'.$ccperrow['id'].'" '.$selected.'>'.$ccperrow['ccper'].'</option>';
					}
					?>
				</select>
			</td>
		</tr>
		<tr>
			<td colspan="3">
				<div id="ccaddr" class="post_subsection" style="display: none; margin: 0px 0px 0px 60px;">
					<span class="inputlabel">Other Location</span>
					<table>
						<tr><td valign="top"><span class="inputlabel">Address:</span></td>
							<td><input type="text" id="cc_addr" name="cc_addr" size="30" value="<?php if($thispost['event_addr']){echo $thispost['event_addr'];} ?>" /></td>
						</tr>
						<tr><td valign="top"><span class="inputlabel">Address2:</span></td>
							<td><input type="text" id="cc_addr2" name="cc_addr2" size="30" /></td>
						</tr>
						<tr><td valign="top"><span class="inputlabel">City,&nbsp;St,&nbsp;Zip:</span></td>
							<td>
								<input type="text" id="cc_city" name="cc_city" size="15" value="<?php if($thispost['cc_city']){echo $thispost['cc_city'];} ?>" />
								<input type="text" id="cc_state" name="cc_state" style="width: 30px;" value="<?php if($thispost['cc_state']){echo $thispost['cc_state'];} ?>" />
								<input type="text" id="cc_zip" name="cc_zip" style="width: 50px;" value="<?php if($thispost['cc_zip']){echo $thispost['cc_zip'];} ?>" />
							</td>
						</tr>
						<tr><td></td><td colspan="2"><span class="inputlabelsmall">a map link will be created for you.</span></td></tr>
					</table>
				</div>
			</td>
		</tr>
		<tr>
			<td colspan="3"><div class="post_editor_title">Childcare Coordinator</div></td>
		</tr>
		<tr>
			<td colspan="2" valign="top">
					<span class="inputlabelsmall">select a coordinator<br />(will auto-fill Contact Details)</span>
					<select id="cc_coordinator_id" name="cc_coordinator_id">
						<option value="-1">--select option--</option>
						<!--<option value="x">(fill in contact at right)</option>--->
						<?php
						while($cc_coordrow = mysql_fetch_array($cc_coordqry)){
							$thisuserid = $cc_coordrow['user_id'];
							$userrow = mysql_fetch_array(dbSelect('users',array("id=$thisuserid")));
						if($thispost[type_id]==$cc_coordrow['id']){$selected = ' SELECTED ';}else{$selected = '';}
						echo '<option value="'.$cc_coordrow['id'].'" '.$selected.'>'.$cc_coordrow['firstname'].' '.$cc_coordrow['lastname'].'</option>';
						}
						?>
					</select>
					<br /><br /><span class="inputlabelsmall">or fill in someone else on the right</span>
			</td>
			<td>
					<table>
						<tr><td colspan="2"><h2><small>Contact Details</small></h2></td></tr>
						<tr><td valign="top"><span class="inputlabel">Name:</span></td>
							<td>
								<input type="text" id="cc_contactname" name="cc_contactname" size="20" value="<?php if($thispost['cc_contactname']){echo $thispost['cc_contactname'];} ?>" />
							</td>
						</tr>
						<tr><td valign="top"><span class="inputlabel">Phone:</span></td>
							<td>
								<input type="text" id="cc_contactphone" name="cc_contactphone" size="20" value="<?php if($thispost['cc_contactphone']){echo $thispost['cc_contactphone'];} ?>" />
							</td>
						</tr>
						<tr><td valign="top"><span class="inputlabel">Email:</span></td>
							<td>
								<input type="text" id="cc_contactemail" name="cc_contactemail" size="30" value="<?php if($thispost['cc_contactemail']){echo $thispost['cc_contactemail'];} ?>" />
							</td>
						</tr>
					</table>
			</td>
		</tr>
	<!---/event childcare--->
	<?php } ?>	
	<?php if($typeid >= 3 && $typeid <= 6){ ?>	
		<tr>
			<td colspan="3"><div class="post_editor_title">The Answer</div></td>
		</tr>
		<tr>
			<td colspan="3"><span class="inputlabel">Date:</span>
				<table>
					<tr>
						<td>
							<input type="text" id="need_answereddate" size="10" name="need_answereddate" onblur="datePickerClosed('need_answereddate');" value="<?php if($thispost['need_answereddate']){echo date('m/d/Y',dateformat($thispost['need_answereddate']));} ?>" />
						</td>
						<td valign="middle"><img src="<?php echo $o['root']; ?>/js/datepicker/cal.png" onblur="datePickerClosed('need_answereddate');" onclick="displayDatePicker('need_answereddate');" /></td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td colspan="3">
				<span class="inputlabel">How? Describe what happened:</span><br />
				<textarea class="mceEditor" id="need_answer" name="need_answer"><?php if($thispost['need_answer']){echo $thispost['need_answer'];} ?></textarea>
			</td>
		</tr>
	<?php } ?>	
</table>
<br />
	<div align="center">
		<input type="text" id="site_id" name="site_id" value="<?php if($siteid && $siteid!=""){echo $siteid;} ?>" />
		<input type="text" id="addtype" name="addtype" value="<?php if($_POST['addtype'] && $_POST['addtype']!=""){echo $_POST['addtype'];} ?>" />
		<input type="text" id="postid" name="postid" value="<?php if($_POST['postid'] && $_POST['postid']!=""){echo $_POST['postid'];} ?>" />
		<input type="submit" id="submit" name="submit" style="font-size: 14pt; color: #00137F; width: 300px;" value="Save" />
	</div>
</div>
</form>

